using System;
using System.Diagnostics;

namespace IBNet
{
   /// <summary>
   /// Describes the state of an order. This class is immutable.
   /// </summary>
   [DebuggerDisplay("{OrderStatus}, InitialMargin = {InitialMargin}, EquityWithLoan = {EquityWithLoan}")]
   public class OrderState
   {
      private readonly OrderStatus orderStatus;
      private readonly string inititialMargin;
      private readonly string maintenanceMargin;
      private readonly string equityWithLoanValue;
      private readonly decimal commission;
      private readonly decimal minimumCommission;
      private readonly decimal maximumCommission;
      private readonly string commissionCurrency;
      private readonly string warningText;

      /// <summary>
      /// Creates a new OrderState.
      /// </summary>
      /// <param name="status">Order Status</param>
      /// <param name="initMargin">Initial margin requirement for the order.</param>
      /// <param name="maintMargin">Maintenance margin requirement for the order.</param>
      /// <param name="equityWithLoan"></param>
      /// <param name="commission"></param>
      /// <param name="minCommission"></param>
      /// <param name="maxCommission"></param>
      /// <param name="commissionCurrency"></param>
      /// <param name="warningText"></param>
      public OrderState(OrderStatus status, string initMargin, string maintMargin,
         string equityWithLoan, decimal commission, decimal minCommission,
         decimal maxCommission, string commissionCurrency, string warningText)
      {
         this.orderStatus = status;
         this.inititialMargin = initMargin;
         this.maintenanceMargin = maintMargin;
         this.equityWithLoanValue = equityWithLoan;
         this.commission = commission;
         this.minimumCommission = minCommission;
         this.maximumCommission = maxCommission;
         this.commissionCurrency = commissionCurrency;
         this.warningText = warningText;
      }

      /// <summary>
      /// Gets the order status.
      /// </summary>
      public OrderStatus OrderStatus { get { return orderStatus; } }

      /// <summary>
      /// Gets the initial margin requirement for the order.
      /// </summary>
      public string InitialMargin { get { return inititialMargin; } }

      /// <summary>
      /// Gets the maintenance margin for the order.
      /// </summary>
      public string MaintenanceMargin { get { return maintenanceMargin; } }

      /// <summary>
      /// Gets the equity with loan value for the order.
      /// </summary>
      public string EquityWithLoanValue { get { return equityWithLoanValue; } }

      /// <summary>
      /// Gets the commission for the order.
      /// </summary>
      public decimal Commission { get { return commission; } }

      /// <summary>
      /// Gets the minimum commission for the order.
      /// </summary>
      public decimal MinimumCommission { get { return minimumCommission; } }

      /// <summary>
      /// Gets the maximum commission for the order.
      /// </summary>
      public decimal MaximumCommission { get { return maximumCommission; } }

      /// <summary>
      /// Gets the commission currency for the order.
      /// </summary>
      public string CommissionCurrency { get { return commissionCurrency; } }

      /// <summary>
      /// Gets the warning text for the order.
      /// </summary>
      public string WarningText { get { return warningText; } }

      public override string ToString()
      {
         string representation = OrderStatus + " InitialMargin: " + InitialMargin +
            "EquityWithLoan: " + EquityWithLoanValue;
         return representation;
      }
   }
}